package com.vcms.cms.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * Topic entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "topic", catalog = "vcms_0.1")
public class Topic implements java.io.Serializable {

	// Fields

	private Integer topicId;
	private Channel channel;
	private String topicName;
	private String shortName;
	private String keywords;
	private String description;
	private String titleImg;
	private String contentImg;
	private String tplContent;
	private Integer priority;
	private Boolean isRecommend;
	private Set<Content> contents = new HashSet<Content>(0);

	// Constructors

	/** default constructor */
	public Topic() {
	}

	/** full constructor */
	public Topic(Channel channel, String topicName, String shortName,
			String keywords, String description, String titleImg,
			String contentImg, String tplContent, Integer priority,
			Boolean isRecommend, Set<Content> contents) {
		this.channel = channel;
		this.topicName = topicName;
		this.shortName = shortName;
		this.keywords = keywords;
		this.description = description;
		this.titleImg = titleImg;
		this.contentImg = contentImg;
		this.tplContent = tplContent;
		this.priority = priority;
		this.isRecommend = isRecommend;
		this.contents = contents;
	}

	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "topicId", unique = true, nullable = false)
	public Integer getTopicId() {
		return this.topicId;
	}

	public void setTopicId(Integer topicId) {
		this.topicId = topicId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "channelId")
	public Channel getChannel() {
		return this.channel;
	}

	public void setChannel(Channel channel) {
		this.channel = channel;
	}

	@Column(name = "topicName", length = 100)
	public String getTopicName() {
		return this.topicName;
	}

	public void setTopicName(String topicName) {
		this.topicName = topicName;
	}

	@Column(name = "shortName", length = 100)
	public String getShortName() {
		return this.shortName;
	}

	public void setShortName(String shortName) {
		this.shortName = shortName;
	}

	@Column(name = "keywords", length = 300)
	public String getKeywords() {
		return this.keywords;
	}

	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}

	@Column(name = "description", length = 500)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "titleImg", length = 300)
	public String getTitleImg() {
		return this.titleImg;
	}

	public void setTitleImg(String titleImg) {
		this.titleImg = titleImg;
	}

	@Column(name = "contentImg", length = 300)
	public String getContentImg() {
		return this.contentImg;
	}

	public void setContentImg(String contentImg) {
		this.contentImg = contentImg;
	}

	@Column(name = "tplContent", length = 100)
	public String getTplContent() {
		return this.tplContent;
	}

	public void setTplContent(String tplContent) {
		this.tplContent = tplContent;
	}

	@Column(name = "priority")
	public Integer getPriority() {
		return this.priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	@Column(name = "isRecommend")
	public Boolean getIsRecommend() {
		return this.isRecommend;
	}

	public void setIsRecommend(Boolean isRecommend) {
		this.isRecommend = isRecommend;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "content_topic", catalog = "vcms_0.1", joinColumns = { @JoinColumn(name = "topicId", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "contentId", nullable = false, updatable = false) })
	public Set<Content> getContents() {
		return this.contents;
	}

	public void setContents(Set<Content> contents) {
		this.contents = contents;
	}

}